/**
 * Created by fangjiahui on 15/12/4.
 */
// 所有模块都通过 define 来定义
define(function (require, exports, module) {

	 //加载模块
    var AjaxReturn = require('/plugins/extend/AjaxReturn');

    require('/plugins/extend/scrollView');
    //加载模板
    var tpl1 = require("/mobile/tpl/invest/investList.tpl");
    $('.home_1').addClass('qd_guide');
    
    require('/plugins/jquery.knob/jquery.knob.min');
	function knobFcn(){
		$('.knob').each(function () {
			var val = parseInt($(this).val());
			if (val == 100) {
				var isIE = function (ver) {
					var b = document.createElement('b');
					b.innerHTML = '<!--[if IE ' + ver + ']><i></i><![endif]-->';
					return b.getElementsByTagName('i').length === 1;
				};
				if (isIE(8)) {
					/*$(this).next().addClass("investComplete100");*/
				}
			}
			$(this).attr("data-fgColor", "#5dc300");
		});
		$('.knob').knob({
			'width': 120,
			'height': 120,
			'thickness': .1
		});
	}
	
	function getData(container,type){
		$.ajax({
	        url: "/app/invest/investList.html?type="+type+"&aprSearch=-1&moneySearch=-1&timeSearch=-1&status=-2&order=5&category=1",
	        type: "get",
	        dataType: "json",
	        success: function (data) {
	            
	            var template = Handlebars.compile(tpl1);
	            var html = template(data);
	            $(container).html(html);
	            knobFcn();
	        }
	    });
	}
	
	getData(".firstList",112);
	
	$(".topMenu span").click(function(){
		var index = $(this).index();
		if(index==1){
			getData(".secondList",103);
		}else{
			getData(".firstList",112);
		}
		$(this).addClass("active").siblings("span").removeClass("active");
		$(".investList").hide().eq(index).show();
	});
});